#pragma once
#ifndef SYNT_H
#define SYNT_H

#include "headers.h"

class SyntacticAnalysis
{
    friend class Parser;
public:
    bool Analyze(QList<Lexeme>*, QTreeWidget*, Error*);
    void PrintDerivationTree();

private:
    ControlTable* actionTable;
    ControlTable* gotoTable;

    const QList<Rule>* rules;

    QTreeWidget* tree;
    Error* error;

    bool Reduse(const Rule*, QList<int>*);

    void ClearTree();
    void ExpandTree();
    void AppendNodeToTree(QString, int);
    void SetTopLevelItem(QString);
    const Rule* GetRule(int);
    void ClearError();
    void SetError(Error);

    void SetRules(const QList<Rule>*);
};

#endif // SYNT_H
